const mysql=require('mysql');

const pool=mysql.createPool({
    connectionLimit:10,
    host:"127.0.0.1",
    user:"root",
    password:"123456",
    database:"test",

});
/**
 * 
 * 
 * @returns {Promise}
 */
function query(sql,values){
    return new Promise((resolve,reject)=>{
        pool.getConnection((error,connection)=>{
            if(error){
                reject(error);
            }else{
                connection.query(sql,values,(error,results)=>{
                    connection.release();
                
                    if(error){
                        reject(error);
                    }else{
                        resolve(results);
                    }
                });

            }

        });

    })
}


module.exports={ query };